package dictcn.com.control;
import java.io.IOException;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;

public class DisServeCon {//远程访问服务器数据库类
	
	//远程服务器地址
	public static String server="http://192.168.0.103:8080/HCCD_WEB";
	public static HttpClient hc =null;
	
	public DisServeCon()
	{
		hc = new HttpClient();
	}
	public String sayHello(String name)
	{
		//请求参数设置
		PostMethod postMethod = new PostMethod(server+"/getGetWordInfoAction.action");
		postMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET,"utf-8");
		
		//设置要查询的单词内容----name
		postMethod.setParameter("word",name);
		
		//str保存查询的结果
		String str="";
		try {
			hc.executeMethod(postMethod);
			str= postMethod.getResponseBodyAsString();
		} catch (IOException e) {
			e.printStackTrace();
		}
		finally
		{
			postMethod.releaseConnection();
		}
		return str;
	}
}
